package com.zhuss.core.information;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.core.information.CreateInformationBo;
import com.zhuss.bean.bo.core.information.DeleteInformationBo;
import com.zhuss.bean.bo.core.information.UpdateInformationBo;
import com.zhuss.bean.bo.core.information.StartInformationBo;
import com.zhuss.bean.bo.core.information.StopInformationBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;

/**
 * @description: 通知公告操作的Service
 * @author: zhushanshuo
 * @create: Tue Feb 02 15:16:28 CST 2021
 **/
@Component("informationOperateService")
public class InformationOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("informationCreate")
	private Processor<Object, CreateInformationBo> informationCreate;
	
	@Autowired
	@Qualifier("informationUpdate")
	private Processor<Object, UpdateInformationBo> informationUpdate;
	
	@Autowired
	@Qualifier("informationDelete")
	private Processor<Object, DeleteInformationBo> informationDelete;
	
	@Autowired
	@Qualifier("informationStart")
	private Processor<Object, StartInformationBo> informationStart;
	
	@Autowired
	@Qualifier("informationStop")
	private Processor<Object, StopInformationBo> informationStop;
	
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws DzcxException {
		
		CreateInformationBo bo = (CreateInformationBo) param;
		
		informationCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws DzcxException {
    	
		UpdateInformationBo bo = (UpdateInformationBo) param;
		
		informationUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws DzcxException {
		
		DeleteInformationBo bo = (DeleteInformationBo) param;
		
		informationDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 启用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void start(Object param) throws DzcxException {
		
		StartInformationBo bo = (StartInformationBo) param;
		
		informationStart.process(bo);
		
		return null;
	}
	
	/**
	 * 停用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void stop(Object param) throws DzcxException {
		
		StopInformationBo bo = (StopInformationBo) param;
		
		informationStop.process(bo);
		
		return null;
	}
	
}

